<?php

declare(strict_types=1);

namespace app\api\controller;

use app\common\model\User;
use app\common\model\Pro;
use app\common\model\District;
use app\common\model\DistrictPro;
use app\common\model\ProNature;
use app\common\model\ProPlace;
use app\common\model\ProCate;
use app\common\model\ProTopic;
use app\common\model\CheckListDetails as CheckListDetailsModel;
use app\common\model\CheckList;


use think\exception\ValidateException;
use think\response\Json;

class CheckListDetails extends Base
{
    /**
     * 提交数据
     */
    public function postData(): Json
    {
        $param = $this->request->post();
        try {
            $this->validate($param, 'CheckListDetails');
            return json(CheckListDetailsModel::postData($param, $this->user));
        } catch (ValidateException $e) {
            return json(['code' => -1, 'msg' => $e->getError()]);
        } catch (\Exception $e) {
            return json(['code' => -1, 'msg' => $e->getMessage()]);
        }
    }
    /**
     * 新建场所
     */
    public function postPlace(): Json
    {
        $param = $this->request->post();
        try {
            return json(CheckListDetailsModel::postPlace($param, $this->user));
        } catch (ValidateException $e) {
            return json(['code' => -1, 'msg' => $e->getError()]);
        } catch (\Exception $e) {
            return json(['code' => -1, 'msg' => $e->getMessage()]);
        }
    }
    //二检三检提交数据
    public function postCheckData(): Json
    {
        $param = $this->request->post();
        try {
            // $this->validate($param, 'CheckListDetailsSgin');
            return json(CheckListDetailsModel::postCheckData($param, $this->user));
        } catch (ValidateException $e) {
            return json(['code' => -1, 'msg' => $e->getError()]);
        } catch (\Exception $e) {
            return json(['code' => -1, 'msg' => $e->getMessage()]);
        }
    }
    /**
     * 上传整改图片
     */
    public function postReform(): Json
    {
        $param = $this->request->post();
        try {

            return json(CheckListDetailsModel::postReform($param, $this->user));
        } catch (ValidateException $e) {
            return json(['code' => -1, 'msg' => $e->getError()]);
        } catch (\Exception $e) {
            return json(['code' => -1, 'msg' => $e->getMessage()]);
        }
    }
}
